<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>积分审核</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />

    <link rel="stylesheet" href="assets/css/amazeui.min.css" />
<link rel="stylesheet" href="assets/css/amazeui.datetimepicker.css" />
    <link rel="stylesheet" href="assets/css/app.css">
    <link rel="stylesheet" href="assets/css/main.css">
    <script src="assets/js/jquery.min.js"></script>
        <script charset="utf-8" src="assets/kindeditor/kindeditor-all.js"></script>
        <script charset="utf-8" src="assets/kindeditor/lang/zh-CN.js"></script>
    <script>
        let name = sessionStorage.getItem("username");
        if (name === null) {
            alert("您还未登录，请登录！");
            window.location.href = "login.html";
        }
    </script>
    <style>
        #title1{
            font-size: 18px;
        }
        #title2{
            font-size: 22px;
            text-align: center;
            color: red;
        }
        .sh_jf{
            display: none;
        }
    </style>
</head>
<body data-type="index">
    <script src="assets/js/theme.js"></script>
    <div class="am-g tpl-g">
        <!-- 头部 -->
<div id="personSettings"></div>
<header class="main_header">

    <!-- 右侧内容 -->
    <div class="tpl-header-fluid">


        <!-- 其它功能-->
        <div class="am-fr tpl-header-navbar">
            <ul>
                <!-- 欢迎语 -->
                <li class="am-text-sm tpl-header-navbar-welcome">
                    <a href="javascript:;">欢迎你, <span id="name"></span> </a>
                </li>
                <!--个人设置-->
                <li class="am-text-sm" data-am-modal="{target: '#settings'}" onclick="settings()">
                    <a href="javascript:;">
                        <span class="am-icon-user"></span> 个人设置
                    </a>
                </li>

                <!--退出系统-->
                <li class="am-text-sm" onclick="exit()">
                    <a href="javascript:;">
                        <span class="am-icon-sign-out"></span> 退出系统
                    </a>
                </li>
            </ul>
        </div>
    </div>
</header>



        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">
            <div class="am-panel am-panel-default" id="postId">
                <div class="am-panel-bd" style="display: flex;justify-content: flex-start;align-items: center">
                    <!-- <a class="flexMenu " data-am-modal="{target:'#my-popup'}" onclick="clearFile()" href="javascript:void(0)">
                        <img src="assets/img/tjbh.png">
                        <p>积分提报</p>
                    </a> -->
                    <a class="flexMenu" href="integral_ranking.html?type=2">
                        <img src="assets/img/backup.png">
                        <p>返回</p>
                    </a>
                </div>
            </div>

            <div class="row-content am-cf">

                <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <!-- <div class="widget-head  am-fr">
                                <div class="am-u-sm-12 am-u-md-12 am-u-lg-4" id="sh_examine">
                                
                                <label>
                                    <input type='radio' name='tiaojian' value='1'>
                                    已通过
                                </label>
                                <label>
                                    <input type='radio' name='tiaojian'  value='2'>
                                    已无效
                                </label>
                                <label>
                                    <input type='radio' name='tiaojian' value='3' >
                                    已废除
                                </label>
                            </div> -->
                            <div class="am-u-sm-12 am-u-md-12 am-u-lg-3 am-fr">
                                <div class="am-input-group am-input-group-sm  cl-p">
                                <!--    <input type="text" class="am-form-field " placeholder="搜索" id="input">
                                    <span class="am-input-group-btn">
                                        <button class="am-btn  am-btn-default am-btn-success tpl-table-list-field am-icon-search search_type1" type="button"></button>
                                    </span>
                                </div> -->
                            </div>
                            </div>

                            <div class="widget-body  am-fr">
                                <div class="am-u-sm-12 am-scrollable-horizontal">
                                    <table width="100%" id="table" class=" am-table-hover am-text-nowrap am-table-bordered am-table-centered am-table am-table-compact am-table-striped tpl-table-black ">
                                        <thead>
                                            <tr>
                                                <th>序号<!-- <input type="checkbox" id="checkAll" name="selectAll"> --></th>
                                                <th>积分单位</th>
                                                <th>积分类别</th>
                                                <th>积分名目</th>
                                                <th>分值</th>
                                                <th>积分日期</th>
                                                <th>审核状态</th>
                                                <!-- <th>操作时间</th>
                                                <th>操作人</th>

                                                <th class="cz">操作</th> -->
                                            </tr>
                                        </thead>
                                        <tbody id="show">
                                            <!-- more data -->
                                        </tbody>
                                    </table>
                                </div>
                                <div class="am-u-lg-12 am-cf">

                                    <div class="am-fr">
                                        <ul class="fenye am-pagination tpl-pagination">
                                            <li class="am-active"><a class="first" href="#">首页</a></li>
                                            <li><a href="#" class="up">上一页</a></li>
                                            <li><a href="#" class="down">下一页</a></li>
                                            <li><a class="last" href="#">末页</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--添加新闻-->

    <div class="am-popup am-modal-active" id="my-popup" style="height: 370px;z-index: 1302; border: 1px solid rgb(204, 204, 204); width: 800px; ">
        <div class="am-popup-inner">
            <div class="am-popup-hd">
                <h4 class="am-popup-title">信息填报</h4>
                <input type="hidden" id="getId">
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>
                    x
                    <!-- &times; -->
                </a>
            </div>
            <div class="am-popup-bd" style="height: 100%;background: #ecf2ff;overflow: scroll;">
                <form class="am-form-horizontal" method="post" enctype="multipart/form-data">
                    <table width="100%" cellspacing="2" cellpadding="1" style="border-spacing: 5px" border="0" id="zqmzTable">
                        <tbody class="tbody4">
                            <tr>
                                <td colspan="2">
                                    <span style="font-size: 10pt;color: maroon">状态：添加...</span>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" style="font-size: 9pt;" colspan="2">
                                    <span style="background-color: #aac9f2;padding: 2px 9px"></span>=必填项 <!-- ＃=输入数字 -->
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" style="background-color: dimgray; height: 1px;width: 100%"></td>
                            </tr>
                            <tr>
                                <td width="50" class="TN_BASIC">积分单位</td>
                                <td>
                                    <input type="text" id="title" style="width: 50%;" readonly="true">
                                </td>
                            </tr>
                            <tr>
                                <td width="50" class="TN_BASIC">联系电话</td>
                                <td>
                                    <input type="text" id="t_tel" style="width: 50%;" readonly="true">
                                </td>
                            </tr>
                            <tr>
                                <td width="50" class="TN_BASIC">积分类别</td>
                                <td>
                                    <select name="" id="t_lb" style="width: 40%;">
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td width="50" class="TN_BASIC">积分明目</td>
                                <td>
                                    <select class="sh1" name="" id="t_mm" style="width: 40%;">
                                        <option value="">请选择明目</option>
                                    </select>
                                    <input class="sh2" type="text" id="t_mm2" style="width: 40%;display: none;">
                                </td>
                            </tr>
                            <tr>
                                <td width="50" class="TN_BASIC">积分分值</td>
                                <td>
                                    <input class="sh3" type="text" id="t_jf" style="width: 50%;" readonly="true">

                                    <input class="sh4" type="text" id="t_jf2" style="width: 50%;display: none;">
                                </td>
                            </tr>
                            <tr>
                                <td width="50" class="TN_BASIC" style="background: #CCDDFF">备注</td>
                                <td>
                                    <input type="text" id="t_bz" style="width: 90%;">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <button type="button" class="btnImg60" id="add" onclick="submitMsg()">提交</button>
                    <button type="button" class="btnImg60" id="add2" onclick="submitMsg2()">草稿</button>


                    <button type="button" class="btnImg60" id="rechange" onclick="rechangeMsg()">确定</button>

                    <button type="button" class="btnImg60" data-am-modal-close="">取消</button>
                </form>
            </div>
        </div>
    </div>

 
    <!--修改委员弹窗-->
    <div class="am-popup am-modal-active" id="modal1" style="z-index: 1302; border: 1px solid rgb(204, 204, 204); width: 800px; ">
        <div class="am-popup-inner">
            <div class="am-popup-hd">
                <h4 class="am-popup-title" id="title1"></h4>
                <span data-am-modal-close class="am-close">×</span>
            </div>
            <div class="am-popup-bd" style="height: 100%;overflow: scroll;">
                <table class="show_content">
                    <tr>
                        <td>
                            积分单位
                        </td>
                        <td class="c_dw"></td>
                    </tr>
                    <tr>
                        <td>
                            联系电话
                        </td>
                        <td class="c_tel"></td>
                    </tr>
                    <tr>
                        <td>
                            积分类别
                        </td>
                        <td class="c_lb"></td>
                    </tr>
                    <tr>
                        <td>
                            积分名目
                        </td>
                        <td class="c_lm"></td>
                    </tr>
                    <tr>
                        <td>
                            积分分值
                        </td>
                        <td class="c_fz"></td>
                    </tr>
                    <tr>
                        <td>备注</td>
                        <td class="c_bz"></td>
                    </tr>
                    <tr>
                        <td>照片</td>
                        <td class="c_zp" style="padding: 10px;">
                            <a href="javascript:void(0)">
                                <img src="assets/img/aboutme.png" alt="">
                            </a>
                            <a href="javascript:void(0)">
                                <img src="assets/img/aboutme.png" alt="">
                            </a>
                            <a href="javascript:void(0)">
                                <img src="assets/img/aboutme.png" alt="">
                            </a>
                        </td>
                    </tr>
                    <tr>
                        <td>审核意见</td>
                        <td class="c_yj"></td>
                    </tr>
                    <tr>
                        <td>审核结果</td>
                        <td class="c_jg"></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>

    <!--修改委员弹窗-->
    <div class="am-popup am-modal-active" id="modal11" style="z-index: 1302; border: 1px solid rgb(204, 204, 204); width: 800px; ">
        <div class="am-popup-inner">
            <div class="am-popup-hd">
                <h4 class="am-popup-title" id="title1">积分审核</h4>
                <span data-am-modal-close class="am-close">×</span>
            </div>
            <div class="am-popup-bd" style="height: 100%;overflow: scroll;">
                <input type="hidden" id="v_id">
                <table class="show_content">
                    <tr>
                        <td>
                            积分单位
                        </td>
                        <td class="c_dw"></td>
                    </tr>
                    <tr>
                        <td>
                            联系电话
                        </td>
                        <td class="c_tel"></td>
                    </tr>
                    <tr>
                        <td>
                            积分类别
                        </td>
                        <td class="c_lb"></td>
                    </tr>
                    <tr>
                        <td>
                            积分名目
                        </td>
                        <td class="c_lm"></td>
                    </tr>
                    <tr>
                        <td>
                            积分分值
                        </td>
                        <td class="c_fz"></td>
                    </tr>
                    <tr>
                        <td>备注</td>
                        <td class="c_bz"></td>
                    </tr>
                    <tr>
                        <td>照片</td>
                        <td class="c_zp" style="padding: 10px;">
                            <a href="javascript:void(0)">
                                <img src="assets/img/aboutme.png" alt="">
                            </a>
                            <a href="javascript:void(0)">
                                <img src="assets/img/aboutme.png" alt="">
                            </a>
                            <a href="javascript:void(0)">
                                <img src="assets/img/aboutme.png" alt="">
                            </a>
                        </td>
                    </tr>
                    <tr class="sh_jf">
                        <td>加分项分值</td>
                        <td class="input_jf">
                            <input type="text">
                        </td>
                    </tr>
                    <tr>
                        <td>审核意见</td>
                        <td class="t_yj">
                            <textarea name="" id="" cols="" rows="2" style="width: 80%;"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td>审核结果</td>
                        <td class="t_jg">
                            <label for="">
                                <input type="radio" value="1" name="sh" checked="checked">
                                审核通过
                            </label>
                            <label for="">
                                <input type="radio" value="2" name="sh">
                                无效 
                            </label>
                            <label for="">
                                <input type="radio" value="3" name="sh"> 
                                废除
                            </label>
                        </td>
                    </tr>
                </table>
                <div style="text-align: center;margin-top: 60px;">
                    <button type="button" class="btnImg60" onclick="submitsh()">提交审核</button>
                    <button type="button" class="btnImg60" data-am-modal-close="">取消</button>
                </div>
            </div>
        </div>
    </div>
    <!--模态窗口提示成功-->
    <div class="am-modal am-modal-alert " tabindex="-1" id="my-alert" style="z-index: 1310">
        <div class="am-modal-dialog">
            <div class="am-modal-hd users"></div>
            <div class="am-modal-bd alert">

            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn">确定</span>
            </div>
        </div>
    </div>
    <script src="assets/js/amazeui.min.js"></script>
    <script src="assets/js/amazeui.datetimepicker.min.js"></script>
    <script src="assets/js/amazeui.datatables.min.js"></script>
    <script src="assets/js/app.js"></script>
</body>
<script>
    $(function(){
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg); //匹配目标参数
            if (r != null) return unescape(r[2]);
            return null; //返回参数值
        }
        var type_x =getUrlParam('type');
        var nameid =getUrlParam('nameid');

        // if(type_x=="1"){
        //     type_x="1"
        //     $("#sh_examine").show()
        //     $(".am-panel-bd a").eq(0).addClass("menu-bg").siblings().removeClass("menu-bg")
        // }
        // if(type_x=="2"){
        //     type_x="0"
        //     $("#sh_examine").hide()
        //     $(".am-panel-bd a").eq(1).addClass("menu-bg").siblings().removeClass("menu-bg")
        //     //$("#status").html("<option value='1'>视察调研活动</option>")
        // }
        // $(".y_sh").click(function(){
        //     window.location.href="dw_list.html?type=1&&nameid="+nameid+""
        // })
        // $(".w_sh").click(function(){
        //     window.location.href="dw_list.html?type=2&&nameid="+nameid+""
        // })
        


let token = sessionStorage.getItem("token");
let post_id = sessionStorage.getItem("post_id");
//确定模态框
$("#my-alert").on('close.modal.amui', function () {
    window.location.reload();
});
//模态框
$("#my-popup").on('close.modal.amui', function () {
    $("#title").val("");
    $("#out_link").val("");
    //editor.html("");
    $("#time3").attr("value","");
});
//封装提交后的提示
function prompt(data, title, modal) {
    if (data.success === true) {
        $(".users").html("" + title + "");
        $(".alert").html(data.message);
        $('#my-alert').modal({ target: '#my-alert' });
        $("#" + modal + "").modal('close');

    } else {
        $(".users").html("" + title + "");
        $(".alert").html(data.message);
        $('#my-alert').modal({ target: '#my-alert' });
        $("#" + modal + "").modal('close');
    }
}
// kindeditor
KindEditor.ready(function (K) {
    editor = K.create('#editor_id', {
        uploadJson: testurl + 'kindeditor/'

    });
});
$(function () {

    //分页
    let pageNum = 1;
    $(".first").click(function () {
        pageNum = 1;
        loadData(pageNum);
        $(this).parents("li").addClass("am-active");
        $(this).parents("li").siblings().removeClass("am-active");
    });
    $(".last").click(function () {
        pageNum = pages;
        loadData(pageNum);
        $(this).parents("li").addClass("am-active");
        $(this).parents("li").siblings().removeClass("am-active");
    });
    $(".up").click(function () {
        if (pageNum === 1) {
            return false;
        } else {
            pageNum--;
            loadData(pageNum);
        }
        $(this).parents("li").addClass("am-active");
        $(this).parents("li").siblings().removeClass("am-active");
    });
    $(".down").click(function () {
        if (pageNum === pages) {
            return false;
        } else {
            pageNum++;
            loadData(pageNum);
        }
        $(this).parents("li").addClass("am-active");
        $(this).parents("li").siblings().removeClass("am-active");
    });


    loadData(1);
    let user_ids = [];
    let checkedLength = "";
    $("#dbdelete").click(function(){
        $.each($('#show input:checkbox:checked'), function () {
          let userId = $(this).val();

            user_ids.push(userId);
        });
        checkedLength = $('#show input:checkbox:checked').length;
        if(checkedLength <= 0){
            alert("请选中至少一条支部风采！");
            return false;
        }else{
            $.ajax({
                url: testurl + "/branch/deletes",
                type: "post",
                headers: { "Authorization": "Bearer " + token },
                contentType: "application/json",
                data: JSON.stringify({
                    "ids": user_ids //id数组
                }),
                success:function(data){
                    prompt(data,"删除支部风采","")
                }
            })
        }
    });

});


$.ajax({
    url: testurl + "/integral/getIntegralClass",
    type: "post",
    headers: { "Authorization": "Bearer " + token },
    contentType: "application/json",
        data: JSON.stringify({
        }),
    success: function (data) {
        str="<option value=\"\">请选择类别</option>"
        console.log(data.obj)
        $.each(data.obj,function (index, values){
            str +="<option value=\""+values.id+"\">"+values.text_+"</option>"
        })
        $("#t_lb").append(str)
    }
})
$.ajax({
    url: testurl + "/integral/getCompany",
    type: "post",
    headers: { "Authorization": "Bearer " + token },
    contentType: "application/json",
    success: function (data) {
        console.log(data.obj)
        $("#title").val(data.obj.company_name);
        $("#t_tel").val(data.obj.phone);
    }
})


$("#t_lb").change(function(){
    var lm = $("#t_lb").val()
    if (lm=="19") {
        $(".sh1").hide()
        $(".sh2").show()
    }
    else{
        $(".sh2").hide()
        $(".sh1").show()
    }
    if (lm=="19") {
        $(".sh3").hide()
        $(".sh4").show()
    }
    else{
        $(".sh4").hide()
        $(".sh3").show()
    }
    $.ajax({
        url: testurl + "/integral/getIntegralList",
        type: "post",
        headers: { "Authorization": "Bearer " + token },
        contentType: "application/json",
        data: JSON.stringify({
            "id":lm
        }),
        success: function (data) {
            str="<option value=\"\">请选择明目</option>"
            console.log(data.obj)
            $.each(data.obj,function (index, values){
                str +="<option value=\""+values.ids+"\">"+values.text_+"</option>"
            })
            $("#t_mm").html(str)
        }
    })
})
$("#t_mm").change(function(){
    var mm = $("#t_mm").val()
    var lm = $("#t_lb").val()
    $.ajax({
        url: testurl + "/integral/getIntegraCalculus",
        type: "post",
        headers: { "Authorization": "Bearer " + token },
        contentType: "application/json",
        data: JSON.stringify({
            "ids":mm
        }),
        success: function (data) {
            console.log(data.obj)
            $("#t_jf").val(data.obj.remark)
        }
    })
})
//页数
$(".search_type1").click(function(){
    //name=$("#input").val().trim()
    reply_status=$('#sh_examine input[name="tiaojian"]:checked').val();
    // pageSize=$(".pageSize").val()
    // years=$("#years").val().trim()
    loadData(1)
})

$("#sh_examine input").change(function(){
    reply_status=$('#sh_examine input[name="tiaojian"]:checked').val();
    //name=$("#input").val().trim()
    loadData(1)
})
let pages = 1;
let reply_status=""
function loadData(pageNum) {
    $.ajax({
       
        url: testurl + "/integral/listByOne",
        type: "post",
        headers: { "Authorization": "Bearer " + token },
        contentType: "application/json",
        data: JSON.stringify({

            "company_id":nameid,
            "pageNum":pageNum
            
        }),
        success: function (data) {
            let dbmessage = data.obj;
            console.log(dbmessage)
            ssd = Math.ceil(data.pageTotal / data.pageSize);
            pages = ssd;
            str = "";
            $.each(dbmessage, function (index, values) {
                var num= index+1;
                if (values.examine_time === undefined) {
                    values.examine_time = "";
                }
                if (values.examine_user === undefined) {
                    values.examine_user = "";
                }
                if (values.integral_calculus === undefined) {
                    values.integral_calculus = "";
                }
                str += " <tr class=\"gradeX\">\n" +
                   "                                        <td>" + num + "</td>\n" +
                    // "                            <td><input name='selectAll'  class='checked' value=" + values.id + " type='checkbox'></td>\n" +
                    "                                        <td>" + values.company_name + "</td>\n" +
                    "                                        <td>" + values.integral_class + "</td>\n" +

                    "                                        <td><a style=\"cursor:pointer\" data-am-modal=\"{target:'#modal1'}\" onclick=\"getMsg("+values.id+")\">" + values.integral_list + "</a></td>\n" +

                    "                                        <td>" + values.integral_calculus + "</td>\n" +
                    "                                        <td>" + values.create_time + "</td>\n" +
                    "                                        <td>" + values.examine + "</td>\n" +
                   

                    
                        "     </tr>";

            });
            $("#show").html(str);

           

            rules();
        }
    });
}


//选中所有的checkbox框
$('#checkAll[name="selectAll"]').click(function () {
    if ($(this).is(':checked')) {
        $('#show input[name="selectAll"]').each(function () {

            $(this).prop("checked", true);
        });
    } else {
        $('input[name="selectAll"]').each(function () {
            $(this).removeAttr("checked", false);
        });
    }
});


// 提交
submitMsg=function(){
    let t_lb = $("#t_lb").val();
    let t_mm
    let t_jf
    if (t_lb!=="19") {
        t_mm = $('#t_mm option:selected').text();
        t_jf = $("#t_jf").val();
    }
    else{
        t_mm = $('#t_mm2').val();
        t_jf = $("#t_jf2").val();
    }

    let t_bz = $("#t_bz").val();
    //let content = editor.html();
    // if(t_lb === ""){
    //     alert("请填写支部风采标题！");
    //     return false;
    // }else{
        $.ajax({
            async: false,
            url: testurl + "/integral/add",
            type: "post",
            headers: { "Authorization": "Bearer " + token },
            contentType: "application/json",
            data: JSON.stringify({
                "integral_class":t_lb,
                "integral_list":t_mm,
                "integral_calculus":t_jf,
                "status":"1",//1、提交 2 存草稿
                "remarks":t_bz,
                //"file_list":""

            }),
            success: function (data) {
                prompt(data,"添加成功","my-popup")
            }
        })
    }  
// }
// 草稿
submitMsg2=function(){  
    let t_lb = $("#t_lb").val();
    let t_mm
    let t_jf
    if (t_lb!=="19") {
        t_mm = $('#t_mm option:selected').text();
        t_jf = $("#t_jf").val();
    }
    else{
        t_mm = $('#t_mm2').val();
        t_jf = $("#t_jf2").val();
    }

    let t_bz = $("#t_bz").val();
    //let content = editor.html();
    // if(title === ""){
    //     alert("请填写支部风采标题！");
    //     return false;
    // }else{
        $.ajax({
            async: false,
            url: testurl + "/integral/add",
            type: "post",
            headers: { "Authorization": "Bearer " + token },
            contentType: "application/json",
            data: JSON.stringify({
                "integral_class":t_lb,
                "integral_list":t_mm,
                "integral_calculus":t_jf,
                "status":"2",//1、提交 2 存草稿
                "remarks":t_bz,
                //"file_list":""

            }),
            success: function (data) {
                prompt(data,"添加成功","my-popup")
            }
        })
    }  
// }


//修改
editor1=function(e){
    $("#getId").val(e);
    $("#add").hide();
    $("#add2").hide();
    $("#rechange").show();
    $("#file1").show();
    $("#file2").show();
    $.ajax({
        url: testurl + "/branch/detail",
        type: "post",
        headers: { "Authorization": "Bearer " + token },
        contentType: "application/json",
        data: JSON.stringify({
            "id": e
        }),
        success:function(data){
            console.log(data);
            let aaa = data.obj;
            if (aaa.file_name === undefined || aaa.file_path === undefined ) {
                $("#file1").html();
            } else {
                $("#file1").html("<a style=\"color: blue\" target=\"_blank\" href=\"" + testurl + "" + aaa.file_path + "\">" + aaa.file_name + "</a><input style=\"height: 13px\" type=\"checkbox\" name=\"check1\"  >删除");
                $("#upfile1").attr("name", aaa.file_name);
                $("#upfile1").attr("path", aaa.file_path);
            }
            if (aaa.pic_name === undefined || aaa.pic_path === undefined) {
                $("#file2").html();
            } else {
                $("#file2").html("<a style=\"color: blue\" target=\"_blank\" href=\"" + testurl + "" + aaa.pic_path + "\">" + aaa.pic_name + "</a><input style=\"height: 13px\" type=\"checkbox\" name=\"check2\"   >删除");
                $("#upfile2").attr("name", aaa.pic_name);
                $("#upfile2").attr("path", aaa.pic_path);
            }
            $("#title").val(aaa.title);
            $("#out_link").val(aaa.out_link);
            editor.html(aaa.content);
            $("#time3").attr('value', aaa.pub_times);
        }
    })
}
//清楚文件
clearFile=function(){
    $("#file1").hide();
    $("#file2").hide();
    $("#add").show();
    $("#rechange").hide();
}
//修改
function rechangeMsg(){
 
    let id  = $("#getId").val();
    let title = $("#title").val();
    let out_link = $("#out_link").val();
    let pub_time = $("#time3").val();
    let content = editor.html();

    // 图片上传
    let file_path = "";
    let file_name = "";
    let formData = new FormData();
    let pic1 = document.getElementById("fileUpload1").files;

    for (let j = 0; j < pic1.length; j++) {
        formData.append("" + j + "", pic1[j]);
    }
    $.ajax({
        url: testurl + "/branch/file",
        type: 'post',
        headers: { "Authorization": "Bearer " + token },
        data: formData,
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (data) {
            console.log(data)
            if (pic1[0] != undefined && pic1[0].name != '') {
                $("#upfile1").attr("name", data.obj[0].name);
                $("#upfile1").attr("path", data.obj[0].path);
            }
            file_path = data.obj.path;
            file_name = data.obj.name;

        },
        error: function (data) {
            console.log(data);
        }
    });
    
    if ($("#upfile1").attr("path") != '') {
        if ((pic1[0] == undefined || pic1[0].name == '') && ($("input[name='check1']").length == 0 || $("input[name='check1']")[0].checked)) {
        } else {
            file_name = $("#upfile1").attr("name");
            file_path = $("#upfile1").attr("path");
         
        }
    }






    $.ajax({
        url: testurl + "/branch/update",
        type: "post",
        headers: { "Authorization": "Bearer " + token },
        contentType: "application/json",
        data: JSON.stringify({
            "id": id,
            "title": title,//标题
            "binary_path": file_path,
            "binary_name": file_name,
            "content": content
        }),
        success:function(data){
            prompt(data,"修改支部风采","my-popup")
        }
    })
}
//标题点开
getMsg=function(e){
    $(".c_dw").html("");
    $(".c_tel").html("");
    $(".c_lb").html("");
    $(".c_lm").html("");
    $(".c_fz").html("");
    $(".c_bz").html("");
    $(".c_yj").html("");
    $(".c_jg").html("");
    $(".c_zp").html("");
    $.ajax({
        url: testurl + "/integral/detail",
        type: "post",
        headers: { "Authorization": "Bearer " + token },
        contentType: "application/json",
        data: JSON.stringify({
            "id": e
        }),
        success:function(data){
            console.log(data);
            var str=""
            $("#title1").html(data.obj.integral_list);
            $(".c_dw").html(data.obj.company_name);
            $(".c_tel").html(data.obj.phone);
            $(".c_lb").html(data.obj.integralClassName);
            $(".c_lm").html(data.obj.integral_list);
            $(".c_fz").html(data.obj.integral_calculus);
            $(".c_bz").html(data.obj.remarks);
            $(".c_yj").html(data.obj.examine_opinion);
            $(".c_jg").html(data.obj.examine);
     

            $.each(data.obj.file_list, function (index, values) {
                str+="<a href=\'"+values.url+"\' target=\"_blank\">\
                        <img src="+values.url+">\
                    </a>"
            })
            $(".c_zp").append(str);
     
        }
    })
}
submitsh=function(){
    var id = $("#v_id").val()
    var input_jf = $(".sh_jf input").val();
    var  examine_opinion= $(".t_yj textarea").val();
    var  examine= $('.t_jg input[name="sh"]:checked').val();
    if (examine=="") {
        alert("请填写审核结果");
        return false;
    }

    if($(".c_fz").text()==""){
        if (isNaN(input_jf) || input_jf == "") {
            alert("请填写正确的分值");
            return false;
        }
    }
    


    $.ajax({
        url: testurl + "/integral/examine",
        type: "post",
        headers: { "Authorization": "Bearer " + token },
        contentType: "application/json",
        data: JSON.stringify({
            "id":id,
            "examine":examine,//1、审核通过 2、无效 3、废除
            "examine_opinion":examine_opinion,
            "integral_calculus":input_jf
        }),
        success:function(data){
            prompt(data,"审核","my-popup")
        }
    })
}
//审核
getsh=function(e,shx){
    if (shx==undefined) {
        $(".sh_jf").show()
    }
    $(".c_dw").html("");
    $(".c_tel").html("");
    $(".c_lb").html("");
    $(".c_lm").html("");
    $(".c_fz").html("");
    $(".c_bz").html("");
    $(".c_yj").html("");
    $(".c_jg").html("");
    $(".c_zp").html("");
    $("#v_id").val("")
    $.ajax({
        url: testurl + "/integral/detail",
        type: "post",
        headers: { "Authorization": "Bearer " + token },
        contentType: "application/json",
        data: JSON.stringify({
            "id": e
        }),
        success:function(data){
            console.log(data);
            var str=""
            $("#title1").html(data.obj.integral_list);
            $(".c_dw").html(data.obj.company_name);
            $(".c_tel").html(data.obj.phone);
            $(".c_lb").html(data.obj.integralClassName);
            $(".c_lm").html(data.obj.integral_list);
            $(".c_fz").html(data.obj.integral_calculus);
            $(".c_bz").html(data.obj.remarks);
            $(".c_yj").html(data.obj.examine);
            $(".c_jg").html(data.obj.examine_opinion);
     
            $("#v_id").val(data.obj.id)
            $.each(data.obj.file_list, function (index, values) {
                str+="<a href=\'"+values.url+"\' target=\"_blank\">\
                        <img src="+values.url+">\
                    </a>"
            })
            $(".c_zp").append(str);
     
        }
    })
}

    })
</script>
</html>